//
//  GamePageViewController.m
//  gamebox_qpp
//
//  Created by 赵隆杰 on 2022/1/6.
//

#import "GamePageViewController.h"
#import "GameListViewController.h"

@interface GamePageViewController ()<WMPageControllerDelegate,WMPageControllerDataSource>

@property (nonatomic, strong) NSMutableArray *typeIds;
@property (nonatomic, strong) NSMutableArray *typeNames;

@end

@implementation GamePageViewController

-(instancetype)initWithClassiifys:(NSArray * )spaceClassifys
{
    self = [super init];
    if (self) {
        self.typeIds = [NSMutableArray array];
        self.typeNames = [NSMutableArray array];
        for (GameTypeModel *model in spaceClassifys) {
            [self.typeIds addObject:model.gameTypeId];
            [self.typeNames addObject:model.gameName];
        }
        [self configMenu];
    }
    return self;
}

-(void)configMenu
{
    self.menuViewStyle = WMMenuViewStyleTriangle;
    self.titleColorSelected = kThemeTitleColor;
    self.titles = self.typeNames;
}
- (NSInteger)numbersOfChildControllersInPageController:(WMPageController *)pageController {
    return self.titles.count;
}

- (NSString *)pageController:(WMPageController *)pageController titleAtIndex:(NSInteger)index {
    return self.titles[index];
}

- (UIViewController *)pageController:(WMPageController *)pageController viewControllerAtIndex:(NSInteger)index {
    GameListViewController *vc = [[GameListViewController alloc] initWithType:self.typeIds[index]];
    return vc;
}

- (CGRect)pageController:(WMPageController *)pageController preferredFrameForMenuView:(WMMenuView *)menuView {
    return CGRectMake(0, 0, self.view.width, 44);
}

- (CGRect)pageController:(WMPageController *)pageController preferredFrameForContentView:(WMScrollView *)contentView {
    CGFloat originY = CGRectGetMaxY([self pageController:pageController preferredFrameForMenuView:self.menuView]);
    return CGRectMake(0, originY, SL_WINDOW_WIDTH, self.view.height - originY);
}


@end
